home *** CD-ROM | disk | FTP | other *** search
- package symantec.itools.db.awt;
-
- import java.awt.Event;
- import java.awt.Image;
-
- public class DbDataSource implements DataSource {
- Matrix rowCache = new Matrix();
- Grid view;
- DbDataStore store;
- DbDataUpdater updater;
- MetaTable meta;
- boolean caching = false;
- Data currData;
- int currDataRow;
- int currDataCol;
-
- public DbDataSource(Grid var1, DbDataStore var2, DbDataUpdater var3, MetaTable var4) {
- this.view = var1;
- this.setupSource(var2, var3, var4);
- }
-
- public Grid getView() {
- return this.view;
- }
-
- public void setupSource(DbDataStore var1, DbDataUpdater var2, MetaTable var3) {
- this.store = var1;
- this.store.setDbDataSource(this);
- this.updater = var2;
- this.meta = var3;
- if (this.meta != null) {
- this.meta.setDbDataSource(this);
- }
-
- this.caching = !this.store.supportsCaching();
- }
-
- public void setGrid(Grid var1) {
- this.view = var1;
- }
-
- public void fetchMode(boolean var1) {
- this.store.fetchMode(var1);
- }
-
- public void setDefaultData(Data var1) {
- }
-
- public void setDefaultData() {
- }
-
- public boolean supportsMeta() {
- return this.meta != null;
- }
-
- public Matrix getCache() {
- return this.rowCache;
- }
-
- public int lastCachedRow() {
- return this.rowCache.rows() - 1;
- }
-
- public MetaTable getMetaTable() {
- return this.meta;
- }
-
- public void setupGrid(Grid var1) throws TypeNotSupported {
- if (this.meta == null) {
- throw new TypeNotSupported("MetaTable not set");
- } else {
- this.meta.setupGrid(this.view);
- }
- }
-
- public void commitData() throws TypeNotSupported {
- if (this.currData != null && this.currData.changed()) {
- this.setData(this.currDataRow, this.currDataCol - 1, this.currData);
- this.currData.commit();
- this.currData = null;
- this.currDataRow = -1;
- }
-
- }
-
- public void setCurrentRow(int var1) throws TypeNotSupported {
- this.store.setCurrentRow(var1);
- }
-
- public Data readData(int var1, int var2) throws DataNotAvailable {
- ++var2;
- if (this.currDataRow == var1 && this.currDataCol == var2) {
- return this.currData;
- } else if (this.caching && this.rowCache.contains(var1, var2)) {
- return (Data)this.rowCache.elementAt(var1, var2);
- } else {
- Data var3 = this.store.getData(var1, var2);
- if (this.caching) {
- this.rowCache.addElement(var1, var2, var3);
- this.markClean(var1);
- }
-
- return var3;
- }
- }
-
- public Data getData(Coordinate var1) throws DataNotAvailable {
- return this.getData(var1.row, var1.col);
- }
-
- public Data getData(int var1, int var2) throws DataNotAvailable {
- ++var2;
- if (this.currDataRow == var1 && this.currDataCol == var2) {
- return this.currData;
- } else {
- this.currData = this.readData(var1, var2 - 1);
- this.currDataRow = var1;
- this.currDataCol = var2;
- return this.currData;
- }
- }
-
- public void addResultSetRow(int var1, Data[] var2) {
- for(int var3 = 1; var3 <= var2.length; ++var3) {
- this.rowCache.updateElement(var1, var3, var2[var3 - 1]);
- }
-
- this.markClean(var1);
- }
-
- public void setData(int var1, int var2, Data var3) throws TypeNotSupported {
- ++var2;
- if (this.caching) {
- this.rowCache.updateElement(var1, var2, var3);
- this.markModified(var1);
- } else {
- this.store.update(var1, var2, var3);
- }
- }
-
- public void setData(Coordinate var1, Data var2) throws TypeNotSupported {
- this.setData(var1.row, var1.col, var2);
- }
-
- public String getText(Coordinate var1) throws DataNotAvailable {
- return this.getData(var1).toString();
- }
-
- public void undeleteRow(int var1) throws TypeNotSupported {
- if (this.caching) {
- this.markModified(var1);
- }
-
- this.updater.undeleteRow(var1);
- }
-
- public void deleteRow(int var1) throws TypeNotSupported {
- if (this.caching) {
- this.markDeleted(var1);
- }
-
- this.updater.deleteRow(var1);
- }
-
- public void insertRow(int var1) throws TypeNotSupported {
- this.updater.insertRow(var1);
- }
-
- public int appendRow() throws TypeNotSupported {
- return this.updater.appendRow();
- }
-
- public boolean supports(Coordinate var1, int var2) {
- return var2 == 1;
- }
-
- public Image getImage(Coordinate var1) throws DataNotAvailable {
- return this.getData(var1).toImage();
- }
-
- public boolean handleEvent(Event var1) {
- switch (var1.id) {
- case 54:
- this.rollback();
- case 1005:
- default:
- return false;
- }
- }
-
- public void handleException(int var1, int var2, Exception var3) {
- this.view.handleException(var1, var2, var3);
- }
-
- public int rowState(int var1) {
- return this.store.rowState(var1);
- }
-
- public void clear() {
- this.rowCache.removeAllElements();
- this.currData = null;
- this.currDataRow = -1;
- this.store.clear();
- }
-
- public void refresh() {
- this.rowCache.removeAllElements();
- this.currData = null;
- this.currDataRow = -1;
- this.store.refresh();
- }
-
- public void undoRow(int var1) throws TypeNotSupported {
- this.store.undoRow(var1);
- }
-
- public void save() throws TypeNotSupported {
- this.updater.save();
- }
-
- public boolean isDataEditable(int var1, int var2) {
- if (this.meta != null) {
- try {
- return this.meta.isDataEditable(var1, var2 + 1);
- } catch (DataNotAvailable var3) {
- return false;
- }
- } else {
- return true;
- }
- }
-
- protected void markModified(int var1) {
- if (this.rowCache.contains(var1, 0)) {
- RowState var3 = (RowState)this.rowCache.elementAt(var1, 0);
- var3.markModified();
- } else {
- RowState var2 = new RowState();
- this.rowCache.addElement(var1, 0, var2);
- var2.markNew();
- }
- }
-
- protected void markNew(int var1) {
- RowState var2;
- if (this.rowCache.contains(var1, 0)) {
- var2 = (RowState)this.rowCache.elementAt(var1, 0);
- } else {
- var2 = new RowState();
- this.rowCache.addElement(var1, 0, var2);
- }
-
- var2.markNew();
- }
-
- protected void markDeleted(int var1) {
- RowState var2 = (RowState)this.rowCache.elementAt(var1, 0);
- var2.markDeleted();
- }
-
- protected void markClean(int var1) {
- RowState var2;
- if (this.rowCache.contains(var1, 0)) {
- var2 = (RowState)this.rowCache.elementAt(var1, 0);
- } else {
- var2 = new RowState();
- this.rowCache.addElement(var1, 0, var2);
- }
-
- var2.markClean();
- }
-
- public int validDataRowRange(int var1, int var2) throws DataNotAvailable {
- return this.store.validDataRowRange(var1, var2) - 1;
- }
-
- public int rows() {
- return this.store.rowsRetrieved();
- }
-
- public int fetchAllRows() {
- return this.store.fetchAllRows();
- }
-
- public int type(int var1, int var2) {
- return 1;
- }
-
- public void rollback(int var1, int var2) {
- this.rollback();
- }
-
- public void rollbackCurrentData() {
- this.rollback();
- }
-
- public void rollback() {
- this.currData = null;
- this.currDataRow = -1;
- }
-
- public void commit(int var1, int var2) {
- }
-
- public boolean isMasked(int var1, int var2) {
- return false;
- }
-
- public String getMask(int var1, int var2) throws TypeNotSupported {
- throw new TypeNotSupported("stubbed");
- }
-
- public boolean supportsChoice(int var1, int var2) {
- return false;
- }
-
- public Data[] getChoices(int var1, int var2) throws TypeNotSupported {
- throw new TypeNotSupported("stubbed");
- }
-
- public void setText(int var1, int var2, String var3) {
- }
-
- public void insertChar(int var1, int var2, int var3, char var4) {
- }
-
- public void setText(int var1, int var2, char var3) {
- }
-
- public void appendChar(int var1, int var2, char var3) {
- }
-
- public void clearText(int var1, int var2) {
- }
-
- public void deleteChar(int var1, int var2, int var3) {
- }
-
- public String subString(int var1, int var2, int var3, int var4) {
- return "stubbed";
- }
-
- public void setImage(int var1, int var2, Image var3) {
- }
-
- public String toString(int var1, int var2) {
- return "stubbed";
- }
-
- public Image toImage(int var1, int var2) {
- return null;
- }
-
- public Object getSynchronizationObject() {
- return this.store.getSynchronizationObject();
- }
- }
-